package utils.IDE;

import javax.swing.JOptionPane;
import java.io.*;
import utils.properties.YourJavaPropertiesUtils;

/**
 *
 * @author Juan Carlos García
 */
public class IDEUtils {
    
    private static String currentIDE;
    
    /**
     * This methid checks if exists a current IDE. If exists, return the IDE route.
     * If not exists, the user must to select one.
     * 
     * @return String Our current IDE
     */
    public static String checkCurrentIDE(){
        
        currentIDE = YourJavaPropertiesUtils.getProperty("IDE","properties");
        
        if("blank".equals(currentIDE)){
            
            JOptionPane.showMessageDialog(null,"Hemos detectado que no tienes instalado yourEclipse! \n "
                    + "Selecciona la carpeta de tu IDE favorito para continuar.");
            
            IDESelectorUtils.select();
            
            currentIDE = YourJavaPropertiesUtils.getProperty("IDE","properties");
            
            return currentIDE;
            
        }else{
            return currentIDE;
        }
        
        
    }
    
    /**
     * 
     * This method checks if yourEclipse exists in our system
     * 
     * @return boolean Returns true if exists yourEclipse directory
     */
    public static boolean checkYourEclipse(){
        
        String so = System.getProperty("os.name");
        
        if("Mac OS X".equals(so)){
            
            String yourEclipseRoute = "/Applications/yourEclipse";
            File directory = new File(yourEclipseRoute);
            if(directory.exists()){
                return true;
            }else{
                return false;
            }
            
        }else{
            
            String yourEclipseRoute = "C:/yourEclipse";
            File directory = new File(yourEclipseRoute);
            
            if(directory.exists()){
                return true;
            }else{
                return false;
            }
            
        }
        
    }
    
}
